package jp.co.cos.ittrick.channel.controller.admin;

import jp.co.cos.ittrick.channel.model.CategoryModel;
import jp.co.cos.ittrick.channel.service.CategoryService;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

public class CategoryEditController extends Controller {

    private CategoryService categoryService;

    public CategoryEditController() {
        categoryService = new CategoryService();
    }

    @Override
    public Navigation run() throws Exception {

        String category = asString("category");
        String channel = asString("channel");
        CategoryModel categoryModel = categoryService.getCategoryByKey(Integer.valueOf(category));
        requestScope("categoryModel", categoryModel);
        requestScope("channel", channel);
        requestScope("category", category);

        return forward("categoryEdit.jsp");
    }
}
